import request from '@/utils/request'
import { downFile } from '@/utils/request'

export function listproductEfinition(query) {
  return request({
    url: '/mes/md/product/list',
    method: 'get',
    params: query,
  })
}

//根据名称查询单条unit
export function getUnitmeasure(query) {
  return request({
    url: '/mes/md/product/getUnit/' + query,
    method: 'get',
  })
}


export function getProcessroute(query) {
  return request({
    url: '/mes/md/product/getProcessroute/' + query,
    method: 'get',
  })
}

export function updateUnitmeasure(data) {
  return request({
    url: '/mes/md/unit/updateUnit',
    method: 'post',
    data: data,
  })
}

export function addProductDefine(data) {
  return request({
    url: '/mes/md/product/addProductDefine',
    method: 'post',
    data: data,
    contextType: 'application/json',
  })
}

export function updateProductDefine(data) {
  return request({
    url: '/mes/md/product/updateProductDefine',
    method: 'post',
    data: data,
    contextType: 'application/json',
  })
}

export function getProductBypk(query) {
  return request({
    url: '/mes/md/product/getProductBypk/' + query,
    method: 'get',
  })
}

export function delproduct(id) {
  return request({
    url: '/mes/md/product/delproduct/' + id,
    method: 'delete',
  })
}

// 导出产品
export async function exportProduct(query) {
  await downFile('/mes/md/product/exportProduct/', { ...query })
}
